<html>
<head><meta charset="utf-8"><title>Documenting rustc_ast::ast::Pat · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html">Documenting rustc_ast::ast::Pat</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202653135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202653135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pierwill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202653135">(Jul 02 2020 at 06:05)</a>:</h4>
<p>Hello! (Not sure in this qualifies as a 'topic' on here, but...)</p>
<p>I noticed that this struct <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_ast/ast.rs#L515">https://github.com/rust-lang/rust/blob/master/src/librustc_ast/ast.rs#L515</a> is undocumented. Would it make sense to describe this as "A pattern is a syntax element for matching against the structure of types"? This is close to how the the book describes patterns <a href="https://doc.rust-lang.org/book/ch18-00-patterns.html">https://doc.rust-lang.org/book/ch18-00-patterns.html</a>. Does it make sense in this context?</p>



<a name="202654605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202654605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pierwill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202654605">(Jul 02 2020 at 06:37)</a>:</h4>
<p>Or is it too high-level? <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="202704804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202704804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202704804">(Jul 02 2020 at 15:36)</a>:</h4>
<p>I think that's too oriented at teaching Rust the language and less at documenting the compiler</p>



<a name="202704874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202704874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202704874">(Jul 02 2020 at 15:36)</a>:</h4>
<p>e.g., I think it's not our job to explain what a pattern <em>is</em></p>



<a name="202704895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202704895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202704895">(Jul 02 2020 at 15:36)</a>:</h4>
<p>though I do think giving examples from Rust code is good</p>



<a name="202704962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202704962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202704962">(Jul 02 2020 at 15:36)</a>:</h4>
<p>maybe something like</p>
<p>// AST for a <em>match pattern</em>. Patterns appear in match statements and some other contexts, such as <code>let</code> and <code>if let</code>.</p>



<a name="202704986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202704986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202704986">(Jul 02 2020 at 15:36)</a>:</h4>
<p>Example:</p>



<a name="202705010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202705010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202705010">(Jul 02 2020 at 15:37)</a>:</h4>
<ul>
<li><code>let P = ...</code>, the P is pattern</li>
</ul>



<a name="202705015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202705015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202705015">(Jul 02 2020 at 15:37)</a>:</h4>
<p>etc</p>



<a name="202749878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Documenting%20rustc_ast%3A%3Aast%3A%3APat/near/202749878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pierwill <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Documenting.20rustc_ast.3A.3Aast.3A.3APat.html#202749878">(Jul 02 2020 at 22:09)</a>:</h4>
<p>Thanks, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ! I'll submit a PR along these lines.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>